﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:lakana="http://schemas.gasytek.com/wpf/lakana"
             xmlns:text="clr-namespace:Samples.GasyTek.Lakana.Resources"
             mc:Ignorable="d"
             x:Class="Samples.GasyTek.Lakana.Screens.ContactView"
             Width="600"
             Height="400"
             Background="{DynamicResource WorkspaceBackgroundBrush}"
             Style="{StaticResource ModalScreenStyle}">
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </UserControl.Resources>

    <DockPanel x:Name="LayoutRoot">
        <TextBlock DockPanel.Dock="Top"
                   Text="{Binding UIMetadata.Label}"
                   Foreground="{DynamicResource WindowBackgorundBrush}"
                   FontSize="22"
                   Style="{DynamicResource ScreenTitleStyle}" />
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="20" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="20" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="20" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="20" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="20" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="3*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="20" />
                <ColumnDefinition />
                <ColumnDefinition Width="20" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <!-- FirstName -->
            <TextBlock Grid.Row="1"
                       Text="{lakana:TextResource text:Texts.FirstName}"
                       Style="{DynamicResource FieldTitleStyle}"
                       Grid.Column="1" />
            <TextBlock Grid.Row="1"
                       Grid.Column="2"
                       Text="*"
                       Foreground="{DynamicResource MetroRedBrush}"
                       VerticalAlignment="Center"
                       FontSize="14.667"
                       HorizontalAlignment="Center" />
            <TextBox Grid.Row="1"
                     Grid.Column="3"
                     Text="{lakana:PropertyBinding FirstName.Value}"
                     Style="{DynamicResource TextBoxStyle}" />

            <!-- LastName -->
            <TextBlock Grid.Row="3"
                       Text="{lakana:TextResource text:Texts.LastName}"
                       Style="{DynamicResource FieldTitleStyle}"
                       Grid.Column="1" />
            <TextBlock Grid.Row="3"
                       Grid.Column="2"
                       Text="*"
                       Foreground="{DynamicResource MetroRedBrush}"
                       VerticalAlignment="Center"
                       FontSize="14.667"
                       HorizontalAlignment="Center" />
            <TextBox Grid.Row="3"
                     Grid.Column="3"
                     Text="{lakana:PropertyBinding LastName.Value}"
                     Style="{DynamicResource TextBoxStyle}" />

            <!-- Phone -->
            <TextBlock Grid.Row="5"
                       Text="{lakana:TextResource text:Texts.Phone}"
                       Style="{DynamicResource FieldTitleStyle}"
                       Grid.Column="1" />
            <TextBlock Grid.Row="5"
                       Grid.Column="2"
                       Text="*"
                       Foreground="{DynamicResource MetroRedBrush}"
                       FontSize="14.667"
                       HorizontalAlignment="Center" />
            <TextBox Grid.Row="5"
                     Grid.Column="3"
                     Text="{lakana:PropertyBinding PhoneNumber.Value}"
                     Style="{DynamicResource TextBoxStyle}" />
            <Border Grid.Row="5"
                    Grid.Column="4"
                    Width="10" 
                    Height="10">
                <ContentControl Style="{DynamicResource BusyIndicatorStyle}"
                                Foreground="{DynamicResource MetroGreenBrush}"
                                Visibility="{Binding PhoneNumber.IsValidating, Converter={StaticResource BooleanToVisibilityConverter}}"
                                Width="10"
                                Height="10" />
            </Border>

            <!-- Email -->
            <TextBlock Grid.Row="7"
                       Text="{lakana:TextResource text:Texts.Email}"
                       Style="{DynamicResource FieldTitleStyle}"
                       Grid.Column="1" />
            <TextBox Grid.Column="3"
                     Grid.Row="7"
                     Text="{lakana:PropertyBinding Email.Value}"
                     Style="{DynamicResource TextBoxStyle}" />

            <!-- Date of birth -->
            <TextBlock Grid.Row="9"
                       Text="{lakana:TextResource text:Texts.DateOfBirth}"
                       Style="{DynamicResource FieldTitleStyle}"
                       Grid.Column="1" />
            <DatePicker Grid.Row="9"
                        Grid.Column="3"
                        Style="{DynamicResource DatePickerStyle}" 
                        DisplayDate="{lakana:PropertyBinding DateOfBirth.Value}"
                        SelectedDate="{lakana:PropertyBinding DateOfBirth.Value}" />

            <!-- Date of death -->
            <TextBlock Grid.Row="11"
                       Text="{lakana:TextResource text:Texts.DateOfDeath}"
                       Style="{DynamicResource FieldTitleStyle}"
                       Grid.Column="1" />
            <DatePicker Grid.Column="3"
                        Grid.Row="11"
                        Style="{DynamicResource DatePickerStyle}"
                        DisplayDate="{lakana:PropertyBinding DateOfDeath.Value}"
                        SelectedDate="{lakana:PropertyBinding DateOfDeath.Value}" />

            <StackPanel Grid.Row="12"
                        Orientation="Horizontal"
                        Grid.ColumnSpan="6"
                        HorizontalAlignment="Center">
                <Button Content="{lakana:TextResource text:Texts.Save}"
                        Style="{DynamicResource ActionButtonStyle}"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        MinWidth="120"
                        Margin="0,0,10,0" 
                        Command="{Binding SaveCommand}" />
                <Button Content="{lakana:TextResource text:Texts.Cancel}"
                        Style="{DynamicResource ActionButtonStyle}"
                        VerticalAlignment="Center"
                        MinWidth="120"
                        Margin="9.998,0,0,0"
                        HorizontalAlignment="Center"
                        Command="{Binding CancelCommand}" />
            </StackPanel>

        </Grid>
    </DockPanel>
    
</UserControl>